#include <stdio.h>
#include "thread_pool.h"

#define MAX_THREAD (10)
void *do_it(void *arg)
{
    printf("hello! arg = [%d]\n", *(int *)arg);
    sleep(2);
}

int main()
{
    int ret = 0;
    int i;
    thread_pool_t *pool = NULL;

    //ret = thread_pool_init(&pool, MAX_THREAD);
    ret = thread_pool_init(&pool, 1);
    if (ret < 0)
    {
        printf("[%s][%d] Create thread pool failed!\n", __FILE__, __LINE__);
        return -1;
    }

    for(i = 0; i < 20; i++)
    {
        ret = thread_pool_add_worker(pool, do_it, (void *)&ret);
        if(ret < 0)
        {
            printf("thread_pool_add_worker err! i = [%d] ret = [%d]\n", i, ret);
            break;
        }
    }

    sleep(50);
    return 0;
}
